package com.osmino.contacts.list;

import java.util.List;
import java.util.Map;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import com.osmino.contacts.R;
import com.osmino.contacts.entity.Group;
import com.osmino.core.utils.view.Backgroung;

public class ContactViewGroupItem extends ContactViewBaseItem {

	public ContactViewGroupItem(Context context, IContactViewController controller) {
		super(context, controller);
	}

	@Override
	public void onClick(View v) {
	}

	@Override
	public void setImagesTo(ImageView iv1, ImageView iv2) {
		iv1.setImageDrawable(null);
		Backgroung.setResource(iv2, R.drawable.contact_view_drop_ic_down, R.drawable.contact_view_drop_ic_down_active);
	}

	public void setGroups(Map<Long, Group> groups, List<Long> checkedGroupIds) {
		StringBuilder sb = new StringBuilder();
		for (Long groupId : checkedGroupIds) {
			if (sb.length() > 0) {
				sb.append(" ,");
			}
			Group group = groups.get(groupId);
			sb.append(group.title);
		}
		if (sb.length() == 0) {
			sb.append(getResources().getString(R.string.ungrouped));
		}
		setText1(sb.toString());
		setText2(getResources().getString(R.string.groups));
	}
}
